package com.gdx.javatd;

import java.util.ArrayList;

import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;


public class JavaTD extends ApplicationAdapter {
	private SpriteBatch batch;
	
	private ArrayList<Turret> turrets;
	private ArrayList<Monster> monsters;
	
	private Settlement settlement;

	public void create() {
		batch = new SpriteBatch();
		
		Settlement.setBaseTexture(new Texture("data/settlement_base.png"));
		
		settlement = new Settlement(Gdx.graphics.getWidth()-124, Gdx.graphics.getHeight()-64);
		
		SimpleTurret.setBaseTexture(new Texture("data/turret_base.png"));
		SimpleTurret.setGunTexture(new Texture("data/turret_gun.png"));
		
		turrets = new ArrayList<Turret>();
		turrets.add(new SimpleTurret(150, 70));
		
		Sbire.setBaseTexture(new Texture("data/monster_base.png"));
		
		monsters = new ArrayList<Monster>();
		monsters.add(new Sbire(0, 50, settlement));
		monsters.add(new Sbire(50, 0, settlement));
	}

	@Override
	public void render() {
		Gdx.gl.glClearColor(1, 1, 1, 1);
		Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
		
		for (Monster monster : monsters) {
			monster.render(batch);
			monster.step();
		}
		
		for (Turret turret : turrets) {
			turret.render(batch);
			turret.step(monsters);
		}
		
		settlement.render(batch);
	}
}
